﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Baza.EF.BLL;
using Baza.EF.DAL;



namespace Pep_3014_3070.Owners
{
    public partial class Owners : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                checkTipKorisnika();
                checkNumberOfReservation();

            }
        }
        private void checkNumberOfReservation()
        {
            int countReservation = DAOwners.getNumberOfNewReservation_By_OwnerID(Convert.ToInt32(HttpContext.Current.User.Identity.Name));
                Reservation.InnerText = countReservation.ToString();

        }

        public void checkTipKorisnika()
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (Convert.ToInt32(Session["TipKorisnika"]) == 3)
                {
                    Response.Redirect("/UsersHome");
                }
                else if (Convert.ToInt32(Session["TipKorisnika"]) == 2)
                {
                    Response.Redirect("/CustomersHome");
                }
            }
        }

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            checkNumberOfReservation();
        }
    }
}